
class JpghostingPlugin:
	def __init__(self):
		# put all the links this plugins supports here - it will be used to filter supported URLs
		self.supported_sites = ['jpghosting.com']
		self.supported_urls = self.supported_sites

	def get(self, url):
		"""Get a single file from jpghosting"""
		parsed_url = urlparse.urlparse(url)
		if parsed_url[1].find('fileserver') == -1: # this is not a direct URL
			url_to_search = find_attr(parsed_url[4], 'image')
			url = get_img_url(url, url_to_search)
			parsed_url = urlparse.urlparse(url)

		local_file = parsed_url[2].split('images/')[1]
		download_file_with_retries(local_file, url)
		config.report.report_finish(local_file)

	def url_matches(self, url):
		"""Check whether we support this URL"""
		for l in self.supported_urls:
			if url.find(l) != -1:
				return True
		return False

	def version(self):
		"""Return plugin version - when interface changes, the version changes"""
		return 1

modules = [JpghostingPlugin()]
